﻿CREATE PROCEDURE [util].[GetDefaultLogPath]
@DefaultLog NVARCHAR (256) OUTPUT
AS
BEGIN
	DECLARE @RC int
	SET @RC = 0;
	
	EXEC @RC = master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE'
		,N'Software\Microsoft\MSSQLServer\MSSQLServer'
		,N'DefaultLog'
		,@DefaultLog OUTPUT

	IF CHARINDEX('\',@DefaultLog,0) = 0 
	BEGIN
		SET @DefaultLog = @DefaultLog + '\'
	END
	
	IF(@DefaultLog IS NULL)
	BEGIN
		RAISERROR('Unable to retrieve DefaultLog registry string value',16,1)
	END
	
	RETURN(@RC)
END